<template>
  <div>


    <div v-if="showsign" style="width:150px;padding-left: 20px;padding-right:20px;padding-top: 2px">
      <el-card :body-style="{ padding: '0px' }" style="height: 50px;">
        <img alt="图片" style="height: 46px" :src="commonImageSign" class="image">
      </el-card>
    </div>
    <div v-if="!showsign" style="padding-left: 10px;padding-top: 4px;">
      <el-button vNode :disabled="disabled" type="primary" @click="opensign">签字</el-button>
    </div>
  </div>
</template>

<script>


  import { userData } from '../../api/system/user'

  export default {
    name: 'passmessage',
    data() {
      return {
        showsign: false,
        commonImageSign: '',
      }
    },

    mounted() {
      if(this.signActive){
        this.showsign = true;
        this.commonImageSign = _cfg.serverUrl +this.signActive;
      }

    }, 
    watch: {
      signstatus: function () {
        //  console.log(this.signstatus);
      },
      signActive: function () {
        // console.log(this.signActive);
      },
      tableType: function () {
        // console.log(this.tableType);
      },
      commonSign: function () {
      }
    }
    , props: {
      signstatus: {
        type: [String],
      },
      commonSign: {
        type: [String],
      },

      signActive: {
        type: String,
      },
      tableType: {
        type: String,
        default: "全部"
      },
      disabled: {
        type: Boolean,
        default: false
      }
    }, methods: {

      opensign() {
        var _this = this;
        this.$prompt('请输入密码', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',

          inputType: "password",
        }).then((contentVal) => {
           let passParams = {
              password: contentVal.value,
            };
            this.getUserTree(passParams);
        }).catch((error) => {
        });
      },

      getUserTree(pagam){

        userData(pagam).then(response => {
          if (response.code === 200) {
            this.showsign = true;
            this.commonImageSign = _cfg.serverUrl +response.data.avatar;
          } else {
            vm.msgError(response.msg);
          }
        });
      },

    },
  }
</script>

<style scoped>

</style>
